package com.springboot.Service.impl;

import com.springboot.Service.UserService;
import com.springboot.dao.UserMapper;
import com.springboot.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by
 * 白夜行 on 2018/5/10.
 */

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;
    @Transactional
    @Override
    public List<User> getUser() {
        return userMapper.getUser();
    }

    @Override
    public int addUser(User user) {
        return userMapper.insertSelective(user);
    }

    @Override
    public int delUser(Integer id) {
        return userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public User getUserById(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public int UpdateUser(User user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }
}
